using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_QuestTab : UIBaseNode
    {

        #region Template Generate,don't modify
        protected partial class UIB_UIN_QuestTab
        {
            #region ObjectBinding Generate
            public IQIGame.Onigao.Framework.ExToggle toggleTab { protected set; get; }
            public IQIGame.Onigao.Framework.ExArtSpriteNum icon { protected set; get; }
            public IQIGame.Onigao.Framework.ExArtSpriteNum iconOn { protected set; get; }
            public IQIGame.Onigao.Framework.ExProgressBar progressBar { protected set; get; }
            public IQIGame.Onigao.Framework.ExText title { protected set; get; }
            public IQIGame.Onigao.Framework.ExText titleOn { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExToggle>("toggleTab", out var __tbv0);
                this.toggleTab = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExArtSpriteNum>("icon", out var __tbv1);
                this.icon = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExArtSpriteNum>("iconOn", out var __tbv2);
                this.iconOn = __tbv2;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExProgressBar>("progressBar", out var __tbv3);
                this.progressBar = __tbv3;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("title", out var __tbv4);
                this.title = __tbv4;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("titleOn", out var __tbv5);
                this.titleOn = __tbv5;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        public int tabIndex { get; private set; } = -1;
        protected UIB_UIN_QuestTab ui { get; set; }

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_QuestTab();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {
            this.ui.toggleTab.onValueChanged.AddListener(this.OnTogValueChanged);
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        protected override void OnDispose()
        {

        }

        public void Show(int data)
        {
            this.Show();
            this.tabIndex = data;
            int tabValue = APIUIQuest.Tabs[this.tabIndex];
            this.ui.title.text = APIUIQuest.GetTabName(tabValue);
            this.ui.titleOn.text = APIUIQuest.GetTabName(tabValue);

            int _numIcon = tabValue + 1;
            this.ui.icon.SetInt(_numIcon);
            this.ui.iconOn.SetInt(_numIcon);

            this.ui.progressBar.SetValue(0, 1);
        }

        void OnTogValueChanged(bool isOn)
        {
            this.ui.title?.SetActive(!isOn);
        }
    }
}
